Skip to content

Conversation

oliveror
Copy link
Member

Merge after #112. Built on the skip-link branch (it reuses main#main-content); once #112 is merged this PR shows only its own commit.

Changes

  • Page titles (WCAG 2.4.2): new usePageTitle() hook; every route sets the tab title, e.g. "Explore recipes – Recipe Platform", "My Cookbook – …", the recipe's own name on detail pages, "Recipe not found", "Edit title", "Page not found". Previously every page was just "Recipe Platform".
  • Focus after navigation: when the pathname changes, AppShell scrolls to the top and moves focus to main, as a full page load would, so screen readers start on the new page instead of the link that was activated. Focus is not moved:
  • Main is focused rather than the page's h1, because lazily loaded pages (feat(perf): cut initial JavaScript for Explore by about a third #93) render their heading only after their code arrives.

Validation

  • npm run check passes (211 unit tests).
  • New browser test: titles for Explore, recipe detail, Log in, Register, recipe-not-found and 404; focus stays in the search box after searching; focus moves to main after opening a recipe.
  • Real-database and cookie-auth browser tests pass (login → create → detail navigation unaffected).

AI usage

Written with Claude Code (Anthropic) to address a teammate's review of the final-delivery findings. Please review the diff as you would any other contribution.

Closes #103

Keyboard users had to tab through the whole header on every page. A
"Skip to main content" link is now the first tab stop: hidden until
focused, then shown top left in white on the dark text colour. It moves
focus to <main id="main-content" tabIndex={-1}> without adding a hash
to the URL. Browser test covers focus order, visibility, colours and the
focus move.

Closes #102
Every page now sets a document title ("My Cookbook – Recipe Platform",
the recipe's name on detail pages). When the pathname changes, AppShell
scrolls to the top and moves focus to main, as a full page load would, so
screen readers start on the new page. Not on first load, not for query
string changes (search, filters, paging) and not while a dialog is open.

Closes #103
@oliveror oliveror requested a review from a team as a code owner November 16, 2026 14:17
Copy link
Member

@olestan olestan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No merge blockers found, but a few issues worth addressing:

  • Back/Forward navigation (AppShell.tsx:23): Scrolling to the top on every pathname change prevents users from returning to their previous scroll position. Consider preserving scroll restoration for browser history navigation.
  • Protected routes (CookbookPage.tsx:48): If session restoration fails, the page title can remain from the previous route. Consider setting a title for the authentication error state.
  • Recipe editing (RecipeCreatePage.tsx:877): Unavailable or unauthorized recipes still display "Edit recipe" in the browser tab. The title should reflect the actual error state.

Addressing them would improve navigation consistency and accessibility.

…or states

- AppShell no longer scrolls to the top on Back/Forward (POP), so the
  browser's restored position is kept; focus still moves to main.
- RequireAuth titles its own states ("Restoring session", "Session could
  not be restored"), so a protected page that cannot render no longer
  keeps the previous page's title.
- The edit page titles each state: "Recipe could not be loaded",
  "Recipe unavailable", "Cannot edit recipe"; "Edit <title>" only when
  editing. A PageTitle component sets titles from such branches, since a
  parent's unconditional usePageTitle would override the child page's.
@oliveror
Copy link
Member Author

Thanks for the approval. All three follow-ups are done in the latest commit:

  • Back/Forward: AppShell now skips scrollTo(0) when useNavigationType() is POP. The browser's restored position is kept, and focus still moves to <main> (preventScroll). New Playwright test: scroll down Explore, open a recipe (it starts at the top with focus on main), go Back, and check the earlier scroll position is restored. To be transparent: in Chromium and WebKit this test also passes on the previous commit, because the browser's restoration lands after our scrollTo(0) there; I couldn't run Firefox here. So the test guards the behaviour rather than reproducing a failure, and the change stops the shell from fighting restoration.
  • Protected routes: RequireAuth sets the title for its own states: "Restoring session" and "Session could not be restored". A protected page that can't render no longer shows the previous page's title. Test: start from an old title, open /cookbook with a failing session restore, and check both titles. After Try again succeeds, the title is "My Cookbook".
  • Recipe editing: each state on the edit route has its own title: "Recipe could not be loaded", "Recipe unavailable", "Cannot edit recipe", and "Edit <title>" only when actually editing. Test: owned, someone else's, and malformed id.

These titles are set through a small PageTitle component rendered inside those branches. Calling usePageTitle() unconditionally in a parent would run its effect after the child page's effect and overwrite the page's own title. Both title tests fail on the previous commit.

npm run check (213 unit tests) passes. In the smoke suite, the new test and all others pass except the two keyboard-<select> tests, which fail on macOS because this branch predates the macOS fix on dev (ab0b2b3).

Heads-up: #112 and #116 also touch focus and scroll handling (#112 adds scroll-margin-top to <main> in the same AppShell.css), so whichever merges last may need a small rebase.

…les-focus

# Conflicts:
#	apps/web/src/components/shell/AppShell/AppShell.tsx
#	apps/web/src/features/recipes/RecipeCreatePage.test.tsx
@oliveror
Copy link
Member Author

Merge-order note, to replace my earlier "small rebase" heads-up: this branch contains #112's original skip-link commit (025f1ff), which is still under a change request there; the scroll-margin-top fix is only on #112. To avoid landing the skip link without that fix, I've held this PR. Please merge #112 first, after it's approved; then this one can be updated from dev and merged.

I've merged the latest dev into this branch: conflicts in AppShell.tsx (lazy-page Suspense) and RecipeCreatePage.test.tsx are resolved. The full local CI passes: check (242 unit tests), test:db, test:api and test:e2e (34 tests).

…les-focus

# Conflicts:
#	apps/web/src/components/shell/AppShell/AppShell.css
#	e2e/smoke.spec.ts
@oliveror oliveror merged commit e076311 into dev Nov 17, 2026
2 checks passed
@oliveror oliveror deleted the feature/a11y-route-titles-focus branch November 20, 2026 15:31
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants